package com.livesource.client.web.sourceCode.filesTree;

import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.user.client.ui.ListBox;
import com.livesource.client.LiveSourceGlobalVariables;
import com.livesource.client.web.LiveSourcePage;

/**
 * 
 * @UserInterface
 */
public class SourceFilesFiltersList extends ListBox {

	public static final String VIEW_FEATURES = "Feature";
	public static final String VIEW_USER_INTERFACE = "UserInterface";
	public static final String VIEW_ARCHITECTURE = "Architecture";
	public static final String VIEW_ENTITIES = "Entity";
	public static final String VIEW_CLASS_FILES = "ClassFiles";
	public static final String VIEW_SOURCE_CODE = "Source Code";

	public SourceFilesFiltersList(String selectedView) {

		this.setWidth("200px");

		this.addItem("Features", VIEW_FEATURES);
		this.addItem("Architecture", VIEW_ARCHITECTURE);
		this.addItem("Entities", VIEW_ENTITIES);
		this.addItem("User Interface", VIEW_USER_INTERFACE);
		this.addItem("Class Files", VIEW_CLASS_FILES);
		this.addItem("Source Code", VIEW_SOURCE_CODE);

		this.setSelectedIndex(0);

		if (VIEW_CLASS_FILES.equals(selectedView)) {

			this.setSelectedIndex(4);

		} else if (VIEW_SOURCE_CODE.equals(selectedView)) {

			this.setSelectedIndex(5);
		}

		this.addChangeHandler(new ChangeHandler() {

			@Override
			public void onChange(ChangeEvent event) {

				LiveSourcePage.featuresTreePanel.clear();
				LiveSourcePage.featuresTreePanel.add(new SourceFilesList(
						getValue(getSelectedIndex()),
						LiveSourceGlobalVariables.projectEntries));
			}
		});
	}

}
